$(() => {
    for (let k in all_cats_info) {
        k = toRealName(all_cats_info[k]);
        console.log(k.adopt_allow);
        if (!(k.adopt_allow > 0)) continue;
        let ele = `<span class="module l-module adopt"><img class="sketch" src="/img/cat/${k.pid}"><div class="info_box"><span class="name">${k.name||""}</span><span class="nick">${k.nick||""}</span><svg class="icon sex" aria-hidden="true"><use xlink:href="#icon-nv"></use></svg><br><span class="info">${parseDate(k.age)}</span><br><span class="info">${getRealData('bl',k.adopt_allow).data}</span></div></span>`;
        $("#waitAdopt").append(ele);
    }

    $(".realThread").each((i, e) => {
        e = $(e);
        e.click(() => location.href = `/t/${e.attr('data-real')}`)
    })
});

$(() => {
    let $rankList = new Vue({
        el: "#rankList",
        data: {
            hot: []
        },
        methods: {
            getCat: id => all_cats_info[id],
            getHotCatName: function(num) {
                if (num > this.hot.length) return `就${this.hot.length}只`;
                let cat = this.getCat(this.hot[num - 1].id) || {};
                return cat.b || cat.c || "还没有起名字";
            },
            getHotCatImgUrl: function(num) {
                if (num > this.hot.length) return "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3729149452,3199545084&fm=26&gp=0.jpg";
                let cat = this.getCat(this.hot[num - 1].id) || {};
                return '/img/cat/' + cat.aa;
            },
            getHotCatAmount: function(num) {
                if (num > this.hot.length) return "暂无";
                return this.hot[num - 1].val;
            },
        }
    });
    (async () => {
        let data = await $.get('/cats/hot');
        let arr = [];
        for (let id in data) arr.push({ id: id, val: data[id] });
        arr.sort((a, b) => b.val - a.val);
        $rankList.hot = arr;
    })();
});